<template>
  <div>
    <div>
      <el-dialog
          title="提示"
          :visible.sync="dialogVisible"
          width="80%"

      >
        <span>基础信息</span>

        <el-form  ref="ruleForm" label-width="100px" class="demo-ruleForm">
          <el-row :gutter="10">
           <el-col :span="6">
             <el-form-item label="班级名称:" prop="className">
               <el-input v-model="xyClassInfo.className"></el-input>
             </el-form-item>
           </el-col>
            <el-col :span="6">
              <el-form-item label="班级类型:" prop="type">
                <el-radio v-model="xyClassInfo.type" label="0">前端</el-radio>
                <el-radio v-model="xyClassInfo.type" label="1">UI</el-radio>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="开班时间:" prop="startTime">
                <el-date-picker
                    v-model="xyClassInfo.startTime"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="结束时间:" prop="endTime">
                <el-date-picker
                    v-model="xyClassInfo.endTime"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>


          <el-form-item label="备注:" prop="desc">
            <el-row :gutter="10">
            <el-col :span="12">
              <el-input
                  type="textarea"
                  placeholder="请输入备注"
                  v-model="xyClassInfo.desc"
                  maxlength="30"
                  show-word-limit
              >
              </el-input>
            </el-col>
            </el-row>
          </el-form-item>



        </el-form>
        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click='doSave'>确 定</el-button>
  </span>
      </el-dialog>
    </div>
  </div>


</template>

<script>
import claapi from '@/api/xy/clalast'
export default {
name: "Clazzlog",
data(){
return{
  dialogVisible: false,
  //班级参数
  xyClassInfo:{
    type: '0'
  },
  ruleForm: {
    name: '',
    region: '',
    date1: '',
    date2: '',
    type: [],
    resource: '',
    desc: ''
  },

}

},
methods:{
openlog(val){
  this.dialogVisible = true
  if (val){
    claapi.classDetail({
      id:val
    })
        .then(res=>{
          this.xyClassInfo = res.data
        })
  }

},
  doSave(){
    console.log(this.xyClassInfo)
    let flag;
    if (this.xyClassInfo.id){
      flag = claapi.classUpdata
    }else {
      flag = claapi.classAdd
    }

    console.log(this.xyClassInfo)

    let xyClassInfo =  this.xyClassInfo

flag({
  xyClassInfo
})
    .then(res=>{
      console.log(res)
      if (res.code == true){
        this.$message('保存成功!!')
        this.$emit('refesh')
        // 清空表单
        this.xyClassInfo={}
        this.dialogVisible=false;
      }else {
        this.$message('保存失败!!')
      }
    })
  }
}
}
</script>

<style lang="scss" scoped>

</style>
